package ruifeng.zcj.dig.base.tablayoutview;

import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;

import butterknife.Bind;
import ruifeng.zcj.dig.R;
import ruifeng.zcj.mybase.base.BaseFragment;


public abstract class TabLayoutFragment extends BaseFragment implements TabLayoutIView {

    protected TabLayoutPresenter tabLayoutPresenter;

    @Bind(R.id.tabLayout)
    protected
    TabLayout tabLayout;

    @Bind(R.id.viewpager_forum)
    protected
    ViewPager container;

    @Override
    protected int getContentView() {
        return R.layout.comm_tab_layout;
    }

//    @Override
//    protected void initFragmentConfig() {
//        tabLayoutPresenter.initFragmentConfig();
//    }

    @Override
    protected void onFirstUserVisible() {
        tabLayoutPresenter.onFirstUserVisible();
    }

    @Override
    protected void onUserVisible() {
        tabLayoutPresenter.onUserVisible();
    }

    @Override
    protected void onUserInvisible() {
        tabLayoutPresenter.onUserInvisible();
    }

    @Override
    public void initContainer(PagerAdapter pagerAdapter) {
        container.setOffscreenPageLimit(0);
        container.setAdapter(pagerAdapter);
    }

    @Override
    public void initTabLayout() {
        tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
        tabLayout.setTabTextColors(Color.parseColor("#b3ffffff"), Color.WHITE);
        tabLayout.setupWithViewPager(container);
    }
}
